/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

/**
 *
 * @author SONY
 */
public class MemberService {
    
    MemberDAO memberDAO;
    
    public MemberService() {
        memberDAO = new MemberDAO();
    }
    
    public Member addMember(String firstname, String lastname, String address, String phone, String gender) {
        try {
            int memberid = memberDAO.insert(firstname, lastname, address, phone, gender);
            if (memberid != -1) {
                Member member = new Member(memberid, firstname, lastname, address, phone, gender);
                return member;
            }
        } catch (Exception e) {
            System.err.println(e);
        }
        return null;
    }
    
    public Member getMemberDetails_byMID(int memberID) {
        return memberDAO.search_byMemberID(memberID);
    }
    
    public boolean updateInfo(int MemberID, String FirstName, String LastName, String Address, String Phone, String Gender) {
        try {
            if(memberDAO.update(MemberID, FirstName, LastName, Address, Phone, Gender)) {
                return true;
            }
        } catch (Exception e) {
            System.err.println(e);
        }
        return false;
    }
    
}
